package com.itheima.demo02;

import java.util.ArrayList;
import java.util.Iterator;

public class MainClass03 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("b");
        list.add("c");
        list.add("d");

        /*for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == "b"){
                list.remove(i);
                i--;
            }
        }*/

        /*Iterator<String> it = list.iterator();
        while (it.hasNext()){
            String s = it.next();
            if ("b".equals(s)){
                it.remove();
            }
        }
        System.out.println(list);*/

        Iterator<String> it = list.iterator();
        for (String s : list) {
            System.out.println(s);
        }
    }
}
